package com.example.bigevent.pojo;


import com.example.bigevent.annotation.State;
import com.example.bigevent.validation.ValidationGroup;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import java.util.Date;

@Data
public class Article {

    @NotNull(groups = ValidationGroup.UpdateArticle.class)
    private Integer id;//主键ID

    @NotEmpty(groups = ValidationGroup.AddArticle.class)
    @Pattern(regexp = "^\\S{1,10}$")
    private String title;//文章标题

    @NotEmpty(groups = ValidationGroup.AddArticle.class)
    private String content;//文章内容

//    @NotEmpty(groups = ValidationGroup.AddArticle.class)
    @URL
    private String coverImg;//封面图像

    @State
    private String state;//发布状态 已发布|草稿

    @NotNull(groups = ValidationGroup.AddArticle.class)
    private Integer categoryId;//文章分类id

    private Integer createUser;//创建人ID

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;//创建时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;//更新时间

    //文章所属分类
    private Category category;

    //文章所属用户
    private User user;
}
